home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Halma 1.1.source Folder / Halma ƒ / Halma code ƒ / halma.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-21  |  3.0 KB  |  106 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        halma.c
  4.  
  5. Purpose:    This module handles demo initialization/shutdown and a
  6.             dispatch for the graphic effects and fades.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "halma.h"
  26. #include "program globals.h"
  27. #include "graphics.h"
  28. #include "file interface.h"
  29. #include "error.h"
  30. #include "halma load-save.h"
  31. #include "halma endgame.h"
  32. #include "halma main window.h"
  33. #include "halma board size.h"
  34. #include "halma meat.h"
  35.  
  36. short            gNumRows;
  37. short            gNumColumns;
  38. short            Board[9][9];
  39. short            gNumMoves;
  40. short            gNumJumps;
  41. short            gThisStartRow, gThisStartColumn;
  42. Str255            gThisJumpString;
  43. unsigned char    **gTheFullJumpHandle;
  44.  
  45. void InitTheProgram(void)
  46. {
  47.     short            i,j,k;
  48.     AppFile            myFile;
  49.     
  50.     (**(gTheWindowData[kBoardSize])).dispatchProc=(dispatchProcPtr)BoardSizeWindowDispatch;
  51.     (**(gTheWindowData[kMainWindow])).dispatchProc=(dispatchProcPtr)MainWindowDispatch;
  52.     
  53.     ((**(gTheWindowData[kBoardSize])).dispatchProc)((WindowDataHandle)gTheWindowData[kBoardSize],
  54.         kStartup, 0L);
  55.     ((**(gTheWindowData[kMainWindow])).dispatchProc)((WindowDataHandle)gTheWindowData[kMainWindow],
  56.         kStartup, 0L);
  57.     gTheFullJumpHandle=(unsigned char**)NewHandle(0L);
  58.     InitTheEndGame();
  59.     
  60.     CountAppFiles(&i, &j);
  61.     if ((j>0) && (i==0))
  62.     {
  63.         GetAppFiles(1, &myFile);
  64.         MyMakeFSSpec(myFile.vRefNum, 0, myFile.fName, &gameFile);
  65.         HandleError(GetSavedGame(&gameFile), FALSE);
  66.         for (k=1; k<=j; k++)
  67.             ClrAppFiles(k);
  68.     }
  69. }
  70.  
  71. void NewGame(void)
  72. {
  73.     short            i,j;
  74.     
  75. // init game globals here, stuff that would be saved to disk in saved game
  76.     for (i=0; i<9; i++)
  77.         for (j=0; j<9; j++)
  78.             Board[i][j]=kNoPiece;
  79.     for (i=gNumRows-1; i>gNumRows-4; i--)
  80.         for (j=0; j<3; j++)
  81.             Board[i][j]=kPiece;
  82.     gNumMoves=gNumJumps=0;
  83.     gThisJumpString[0]=0x00;
  84.     gStickyButtonRow=gStickyButtonColumn=-1;
  85.     InitLoadSave();
  86.     StartGame();
  87. }
  88.  
  89. void StartGame(void)
  90. {
  91. // init game globals here, stuff that always needs to be initted
  92.     if (gTheWindow[kBoardSize])
  93.         CloseTheWindow(gTheWindowData[kBoardSize]);
  94.     OpenTheWindow(kMainWindow);
  95. }
  96.  
  97. void ShutDownTheProgram(void)
  98. {
  99.     ShutDownTheEndGame();
  100.     DisposeHandle((Handle)gTheFullJumpHandle);
  101.     ((**(gTheWindowData[kBoardSize])).dispatchProc)((WindowDataHandle)gTheWindowData[kBoardSize],
  102.         kShutdown, 0L);
  103.     ((**(gTheWindowData[kMainWindow])).dispatchProc)((WindowDataHandle)gTheWindowData[kMainWindow],
  104.         kShutdown, 0L);
  105. }
  106.